package com.gitee.feizns.quickstart.ding.talk.api.v10.device.mng.customers.devices.inspect.infos;

import com.aliyun.dingtalkdevicemng_1_0.Client;
import com.aliyun.dingtalkdevicemng_1_0.models.ListInspectInfoRequest;
import com.aliyun.dingtalkdevicemng_1_0.models.ListInspectInfoResponse;
import com.aliyun.dingtalkdevicemng_1_0.models.ListInspectInfoResponseBody;
import com.aliyun.teautil.models.RuntimeOptions;
import com.gitee.feizns.quickstart.ding.talk.client.Clients;
import com.gitee.feizns.quickstart.ding.talk.utils.Utils;
import lombok.SneakyThrows;

/**
 * 获取巡检或保养记录
 * 接口路径：<a href="https://open.dingtalk.com/document/orgapp/obtain-inspection-and-maintenance-records">获取巡检或保养记录（/v1.0/devicemng/customers/devices/inspectInfos/query）</a>
 * @link <a href="https://open.dingtalk.com/document/orgapp/obtain-inspection-and-maintenance-records">服务端API 行业开放 设备上钉 获取巡检或保养记录</a>
 * @author feizns
 * @since 2024/3/18
 */
public class Query {

    /**
     * 获取巡检或保养记录
     * @param accessToken 访问凭据
     * @param req {@link ListInspectInfoRequest}
     * @return {@link ListInspectInfoResponseBody}
     */
    @SneakyThrows
    public static ListInspectInfoResponseBody execute(String accessToken, ListInspectInfoRequest req) {
        Client client = Clients.get(Client.class);
        com.aliyun.dingtalkdevicemng_1_0.models.ListInspectInfoHeaders listInspectInfoHeaders = new com.aliyun.dingtalkdevicemng_1_0.models.ListInspectInfoHeaders();
        listInspectInfoHeaders.xAcsDingtalkAccessToken = accessToken;
        ListInspectInfoResponse resp = client.listInspectInfoWithOptions(req, listInspectInfoHeaders, new RuntimeOptions());
        return Utils.ifErrorThrow(resp.getBody());
    }

}
